﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace NBusiness.Data.Testing.Mocks
{
    class MethodCall
    {
        private static List<MethodCall> _calls = new List<MethodCall>();
        public static IList<MethodCall> Calls
        {
            get { return _calls; }
        }

        private Dictionary<string, object> _values = new Dictionary<string,object>();
        public Dictionary<string, object> Values { get { return _values; } }

        public string Method { get; private set; }

        public MethodCall(string method, params object[] values)
        {
            Method = method;

            foreach (object o in values)
            {
                PropertyInfo nameProperty = o.GetType().GetProperty("Name");
                PropertyInfo valueProperty = o.GetType().GetProperty("Value");

                string name = (string)nameProperty.GetValue(o, null);
                object value = (object)valueProperty.GetValue(o, null);

                Values.Add(name, value);
            }
        }
    }
}
